package org.an.demo.test;

import android.os.Bundle;
import http.Impl;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import org.an.demo.R;
import org.an.demo.module.LanguageTagInfo;
import org.an.demo.module.RightButtonBean;
import org.an.demo.util.DataParseUtil;
import org.an.ku.base.BaseActivity;
import org.json.JSONArray;
import org.json.JSONException;

public class CommonTestActivity extends BaseActivity {

  @Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Type[] genericInterfaces = Impl.class.getGenericInterfaces();
    // 获取 实现的第一个接口
    ParameterizedType parameterizedType = (ParameterizedType) genericInterfaces[0];
    // 获取接口类型 interface http.Callback
    Class cls = (Class) parameterizedType.getRawType();
    // 获取接口的泛型参数
    Type[] argsType = parameterizedType.getActualTypeArguments();
    // class org.an.demo.module.Bean
    Class type = (Class) argsType[0];

    String params = RawUtils.getString(R.raw.array);
    List<String> list = new ArrayList();
    try {
      JSONArray array = new JSONArray(params);
      for (int i = 0; i < array.length(); i++) {
        list.add(array.getString(i));
      }
    } catch (JSONException e) {
      e.printStackTrace();
    }

    //List<String> listData = DataParseUtil.jsonToList(params,String[].class);
    //
    List<LanguageTagInfo> listData1 =
        DataParseUtil.getListData(RawUtils.getString(R.raw.language), LanguageTagInfo[].class);
    List<RightButtonBean> data =
        DataParseUtil.getListData(RawUtils.getString(R.raw.share), RightButtonBean[].class);
  }
}
